Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Quat animation #1

Merged
merged 10 commits into from
Nov 30, 2020
Merged

Quat animation #1

merged 10 commits into from
Nov 30, 2020

Conversation

iwikal
Copy link

@iwikal iwikal commented Oct 27, 2020

This is what I have so far. The Rotation shim is exposed to the public API, which isn't super desirable, but it shows the functionality, at least.

We now have to deal with the nonlinearity of the splines impl for Quat,
though.
@mcpar-land
Copy link
Owner

Be sure to merge my 0.3 update for this! I'll happily merge it when it's done

@iwikal iwikal marked this pull request as ready for review November 26, 2020 18:46
@iwikal
Copy link
Author

iwikal commented Nov 26, 2020

I can't explain why the CI is failing - neither of us wrote that.

@@ -11,7 +10,7 @@ pub enum LoopStyle {
pub trait SplineGroup {
type Sample;

fn splines(&self) -> Vec<&Spline<f32, f32>>;
fn spline_key_times(&self) -> Vec<Box<dyn DoubleEndedIterator<Item = f32> + '_>>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I think we should leave the splines function available for general use alongside your new spline_key_times function, rather than replacing it.

  • Dunno about returning a Vec containing arbitrary iterators. Consider adding another type to the SplineGroup trait instead?

pub trait SplineGroup {
  type Sample;
  type KeyTimes;

  fn spline_key_times(&self) -> KeyTimes;

  // ...

}

impl SplineGroup for AnimationSplineOne {
  type Sample = Option<f32>;
  type KeyTimes = Box<dyn DoubleEndedIterator<Item = f32> + '_>;
  
  // ...

}

Copy link
Author

@iwikal iwikal Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is, there can no longer be an fn splines(&self) -> Vec<&Spline<f32, f32>> on SplineGroup, since not all splines have f32 values - one of them has Quats instead. So I looked around to see what the splines method was used for internally, replaced it with spline_key_times, and didn't really think too hard about how people might want to use it in general. I kind of assumed that it was just a side effect of needing to use it internally, and not having private trait methods. What's the use case?

I was absolutely not pleased with returning a Vec<Box<dyn Iterator>>, but I just wanted to get a proof of concept working. Now that you've brought it back to my attention, I would like to look into if there's a better way to implement start_time, end_time and is_empty on SplineGroup, which to my knowledge are the only things spline_key_times is used for. Maybe we could just leave them as required methods, instead of trying to create a general default implementation that will probably end up needing dynamic dispatch?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is, there can no longer be an fn splines(&self) -> Vec<&Spline<f32, f32>> on SplineGroup, since not all splines have f32 values - one of them has Quats instead.

Ah, true that.

What's the use case?

main one I thought of is that if this is eventually integrated into a UI, you'd want direct access to the splines for drawing them in a curve editor.

Maybe we could just leave them as required methods, instead of trying to create a general default implementation that will probably end up needing dynamic dispatch?

Seems like a good option. Feel free to experiment.

It's worth mentioning that there's Another PR doing animation that uses property names and just seems overall more flexible than the hard-typed implementation we're doing here. It might be a better option entirely.

Copy link
Author

@iwikal iwikal Nov 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth mentioning that there's Another PR doing animation that uses property names and just seems overall more flexible than the hard-typed implementation we're doing here. It might be a better option entirely.

Wow, I hadn't seen that. I'm looking through it now, trying to understand what they're doing.

@iwikal iwikal changed the title Work in progress Quat animation Quat animation Nov 30, 2020
@iwikal
Copy link
Author

iwikal commented Nov 30, 2020

The failing CI is due to a new clippy warning that they have already suppressed in master. It will go away on its own after merging.

@mcpar-land mcpar-land merged commit a86e7cf into mcpar-land:master Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants